#pragma once

#include<iostream>
#include<string>
#include"util.hpp"

namespace ns_log
{
    using namespace ns_util;
    enum
    {
        INFO,
        DEBUG,
        WARNING,
        ERROR,
        FATAL
    };

    std::ostream &Log(const std::string &level, const std::string &file_name, int line)
    {
        //添加日志等级
        std::string message = "[";
        message += level;
        message += "]";

        //添加出错文件名
        message += "[";
        message += file_name;
        message += "]";

        //添加出错行号
        message += "[";
        message += std::to_string(line);
        message += "]";

        //添加时间戳
        message += "[";
        message += TimeUtil::GetTimeStamp();
        message += "]";                                 

        std::cout << message;

        return std::cout;
    }

    //调用：LOG(level) << message;
    #define LOG(level) Log(#level, __FILE__, __LINE__)
}